package com.example.jdktest.other;

import java.util.*;

/**
 * @author: dangwen
 * @createDate: 2021/6/30
 */
public class isValidate {

    public void validate(String strs) {
        ArrayList<String> list = new ArrayList<String>();
        Map<Character, Character> map = new HashMap<>();
        Stack<Character> stack = new Stack<>();
        map.put(')', '(');
        for (int i = 0; i < strs.length(); i++) {
            char c = strs.charAt(i);
            if (c == ')') {
                stack.pop();
            } else if (c == '(') {
                stack.push(c);
            } else {

            }
        }
    }

    public static ArrayList<String> byReplace(String strs) {
        ArrayList<String> list = new ArrayList<String>();
        if (strs.startsWith(")")) {
            return list;
        }
        int index = strs.indexOf("))");
        list.add(strs.substring(0, index + 1) + strs.substring(index + 2));
        list.add(strs.substring(0, index - 1) + "(" + strs.substring(index - 1));
        return list;
    }

    public static void main(String[] args) {
        String ablc = "())";
        ArrayList<String> strings = byReplace(ablc);
        for (String s : strings) {
            System.out.println(s);
        }
    }
}
